//
//  FDDatailViewController.m
//  LANGirl
//
//  Created by 杨泓晔 on 16/3/7.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "FDDatailViewController.h"
#import "FirstDetailTableViewCell.h"//详情里。用户名，用户详情
#import "SedcondDetailTableViewCell.h"
#import "ThirdDetailTableViewCell.h"
#import "UMSocial.h"

@interface FDDatailViewController ()<UITableViewDataSource,UITableViewDelegate,UMSocialUIDelegate>
//@property (nonatomic,retain)UIButton *button;
@property (nonatomic,retain)UIImageView *shoucangV;
@property (nonatomic,retain)UIImageView *shoucangG;
@property (nonatomic,retain)UIImageView *xinImageView;
@property (nonatomic,retain)UIImageView *xinImageView2;

@property(nonatomic,retain)UIView *myheaderView;
@property(nonatomic,retain)UIButton *goBack;
@property(nonatomic,retain)UIButton *SSbution;
@property (nonatomic,retain)UILabel *nameL;
@property (nonatomic,retain)UIImageView *SJImageView;
@property (nonatomic,assign)BOOL isSelrct;
@property (nonatomic,retain)UIView *fenVIE;


@end

@implementation FDDatailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //1.设置self.tabBarController.tabBar.hidden=YES;
             [self createTableView];
    [self tabBarButton];
    self.isSelrct = YES;
    
    
    self.myheaderView = [[UIView alloc]init];
    self.myheaderView.backgroundColor = HH;
    self.myheaderView.userInteractionEnabled = YES;
    //    UITapGestureRecognizer * tapAction = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectAction:)];
    //    [self.myheaderView addGestureRecognizer:tapAction];
    [self.view addSubview:self.myheaderView];
    [self.myheaderView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 139.00*HEIGHT/2));
        
    }];
    
    self.goBack = [[UIButton alloc]init];
    [self.goBack setImage:[UIImage imageNamed:@"back@3x-01.png"] forState:UIControlStateNormal];
    [self.goBack addTarget:self action:@selector(Back:) forControlEvents:UIControlEventTouchUpInside];
    [self.myheaderView addSubview:self.goBack];
    [_goBack mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.myheaderView).offset(51.00*HEIGHT/2);     //  相对于self.view 顶部 10
        make.left.equalTo(self.myheaderView).offset(20.00*WEIGHT/2);    //  相对于self.view 左边 10
        make.size.mas_equalTo(CGSizeMake(34.00*HEIGHT, 34.00*HEIGHT));
        
    }];
    //分享
    self.SSbution = [[UIButton alloc]init];
    [self.SSbution setImage:[UIImage imageNamed:@"fenxiang3p.png"] forState:UIControlStateNormal];
    [self.SSbution addTarget:self action:@selector(fenxiang:) forControlEvents:UIControlEventTouchUpInside];
    [self.myheaderView addSubview:self.SSbution];
    [self.SSbution mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.myheaderView).offset(51.00*HEIGHT/2);     //  相对于self.view 顶部 10
        make.right.equalTo(self.myheaderView).offset(-20.00*WEIGHT/2);    //  相对于self.view 左边 10
        make.size.mas_equalTo(CGSizeMake(30*HEIGHT, 30*HEIGHT));
        
    }];
    
    
    
    UIImageView *SJImageView = [[UIImageView alloc]init];
    UITapGestureRecognizer *SStap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(souSuo:)];
    [SJImageView addGestureRecognizer:SStap];
    SJImageView.image = [UIImage imageNamed:@"90X90@3P-02-01.png"];
    [self.myheaderView addSubview:SJImageView];
    [SJImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.SSbution);
        make.right.equalTo(self.SSbution.mas_left).offset(-20.00*WEIGHT/2);
        make.size.mas_equalTo(CGSizeMake(32.00*HEIGHT, 32.00*HEIGHT));
        

        
    }];

    
    
    
    
    //name
    self.nameL = [UILabel new];
    self.nameL.text = @"dddddd";
    [self.myheaderView addSubview:self.nameL];
    [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.myheaderView).offset(51.00*HEIGHT/2);     //  相对于self.view 顶部 10
        make.left.equalTo(self.goBack.mas_right).offset(230.00*WEIGHT/2);    //  相对于self.view 左边 10
       // make.size.mas_equalTo(CGSizeMake(34.00*HEIGHT, 34.00*HEIGHT));
        make.height.mas_equalTo(34 * AUTO_HEIGHT);
        

        
    }];
    
    
    
    
    
    

    
}
- (void)Back:(UIButton *)backButton{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)fenxiang:(UIButton *)btu{
    NSLog(@"分享");
    
//    [UMSocialSnsService presentSnsIconSheetView:self
//                                         appKey:@"56dff44fe0f55a9069001c87"
//                                      shareText:@"友盟社会化分享让您快速实现分享等社会化功能，http://umeng.com/social"
//                                     shareImage:[UIImage imageNamed:@"icon"]
//                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,nil]
//                                       delegate:self];
//
//
    
    
    
    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    /**
     Sns平台类，用`platformName`作为标识，指定显示名称、显示的图片，点击之后的响应。
     */
    snsPlatform.displayName = @"新浪";
    

    UMSocialSnsPlatform *snsPlatform2 = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToTencent];
    snsPlatform2.displayName = @"腾讯微博";
    

    
    UMSocialSnsPlatform *snsPlatform3 = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToRenren];
    snsPlatform3.displayName = @"微博";
//
    
    
    //分享第二步
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"56dff44fe0f55a9069001c87"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"Icon-29.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToWechatSession,UMShareToWechatTimeline,UMShareToSms,UMShareToQQ,nil]
                                       delegate:self];
    
    

    
    
}
#pragma mark - tableview
- (void)createTableView{
   // self.view.backgroundColor = [UIColor colorWithRed:0.910 green:0.933 blue:0.896 alpha:1.000];
    

    UITableView *tableView = [UITableView new];
    tableView.backgroundColor = LV;
    tableView.separatorStyle = NO;
    //self.navigationController.navigationBar.translucent = NO;
    tableView.frame = CGRectMake(0, 50 * AUTO_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT);
    [self.view addSubview:tableView];
    tableView.delegate = self;
    tableView.dataSource = self;
    [tableView registerClass:[FirstDetailTableViewCell class] forCellReuseIdentifier:@"FirstDetailTableViewCell"];
    [tableView registerClass:[SedcondDetailTableViewCell class] forCellReuseIdentifier:@"SedcondDetailTableViewCell"];
    [tableView registerClass:[ThirdDetailTableViewCell class] forCellReuseIdentifier:@"ThirdDetailTableViewCell"];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
    
    static NSString *str = @"FirstDetailTableViewCell";
    FirstDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str forIndexPath:indexPath];
        //取消点击cell的背景颜色至灰色
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
        
        
        
    }
    if (indexPath.row == 0) {
    
        static NSString *str = @"SedcondDetailTableViewCell";
        SedcondDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str forIndexPath:indexPath];
        //取消点击cell的背景颜色至灰色
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
        
    }
    if (indexPath.row == 2) {
        static NSString *str = @"ThirdDetailTableViewCell";
        ThirdDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str forIndexPath:indexPath];
        //取消点击cell的背景颜色至灰色
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
    }
    return nil;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
     
    return 180;
        
    }
    if (indexPath.row == 0) {
        return 110;
    }
#pragma mark -根据文字自适应高度
    else{
        return 290;
    }
}


#pragma mark - 收藏 ＋ 沟通
- (void)tabBarButton{
    
    for (int i = 0; i < 2; i ++) {
        
        UIView *lowView = [[UIView alloc]init];
        
        lowView.userInteractionEnabled = YES;
        
      //  lowView.backgroundColor = [UIColor colorWithRed:1.000 green:0.172 blue:0.168 alpha:1.000];
        
        [self.view addSubview:lowView];
        
        
        
        [lowView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view.mas_bottom).offset(0);
            
            make.left.equalTo(self.view);
            
            make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 110.00*HEIGHT/2));
            

            
        }];
        
        
        
        
       
            self.shoucangV = [UIImageView new];
            //
            self.shoucangV.image = [UIImage imageNamed:@"316x62@2p.png"];
            //
            [lowView addSubview:self.shoucangV];
            lowView.backgroundColor = [UIColor whiteColor];
            
            [self.shoucangV mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(lowView.mas_top).offset(19.00*HEIGHT/2);
                
                make.left.equalTo(lowView).offset(35.00*WEIGHT/2);
            
                make.size.mas_equalTo(CGSizeMake(316.00*HEIGHT/2, 17.00*AUTO_HEIGHT*2));
                
            }];
            
            
            self.xinImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"50x50@2p-2-01.png"]];
            [self.shoucangV addSubview:self.xinImageView];
            [self.xinImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(self.shoucangV).offset(10.00*HEIGHT/2);
                make.left.equalTo(self.shoucangV).offset(76.00*WEIGHT/2);
                make.size.mas_equalTo(CGSizeMake(50.00*HEIGHT/2, 50.00*HEIGHT/2));
                
            }];
            
            self.xinImageView.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"50x50@2p-1-01.png"],[UIImage imageNamed:@"50x50@2p-2-01.png"],[UIImage  imageNamed:@"50x50@2p-2-03-01.png"], [UIImage  imageNamed:@""],[UIImage  imageNamed:@""],nil];
            self.xinImageView.animationDuration = 2;
            self.xinImageView.animationRepeatCount = 0;
            [self.xinImageView startAnimating];
            
            UITapGestureRecognizer *SCorGT = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(shoucangTap:)];
            
            [lowView addGestureRecognizer:SCorGT];
            
            
            
        
        
        
        
        
        
        
        
      
            
            
        self.shoucangG = [[UIImageView alloc]init];
            //
            self.shoucangG.image = [UIImage imageNamed:@"316x62@2p-2.png"];
            //
            [lowView addSubview:self.shoucangG];
           // lowView.backgroundColor = [UIColor colorWithRed:1.000 green:0.355 blue:0.190 alpha:1.000];
            
            [self.shoucangG mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(lowView.mas_top).offset(19.00*HEIGHT/2);
                
                make.left.equalTo(self.shoucangV.mas_right).offset(35.00*WEIGHT/2);
                
                make.size.mas_equalTo(CGSizeMake(316.00*HEIGHT/2, 17.00*AUTO_HEIGHT*2));
            }];
            self.xinImageView2 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"goutong50x50@2p-02-01.png"]];
      //  self.xinImageView2.backgroundColor = [UIColor redColor];
            [self.shoucangG addSubview:self.xinImageView2];
            [self.xinImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(self.shoucangV).offset(6.00*HEIGHT/2);
                make.left.equalTo(self.shoucangG.mas_left).offset(70.00*WEIGHT/2);
                make.size.mas_equalTo(CGSizeMake(50*HEIGHT/2, 50*HEIGHT/2));
                
            }];
            
            self.xinImageView2.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"goutong50x50@2p-01-01.png"],[UIImage imageNamed:@"goutong50x50@2p-02-01.png"],[UIImage imageNamed:@"goutong50x50@2p-03-01.png"],[UIImage imageNamed:@""],[UIImage  imageNamed:@""], [UIImage  imageNamed:@""],[UIImage  imageNamed:@""],nil];
            self.xinImageView2.animationDuration = 2.5;
            self.xinImageView2.animationRepeatCount = 0;
            [self.xinImageView2 startAnimating];
            UITapGestureRecognizer *GTorGT = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(GTTap:)];
            
            [lowView addGestureRecognizer:GTorGT];



    
}
    
}

- (void)shoucangTap:(UITapGestureRecognizer *)tap{
    NSLog(@"收藏");
}
- (void)GTTap:(UITapGestureRecognizer *)tap{
    NSLog(@"沟通");
}
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden=YES;
    
//    //创建一个导航栏
//    UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64 * AUTO_HEIGHT)];
//   // navBar.backgroundColor = HH;
//    //创建一个导航栏集合
//    UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"ddd"];
//    //在这个集合Item中添加标题，按钮
//    //style:设置按钮的风格，一共有三种选择
//    //action：@selector:设置按钮的点击事件
//    //创建一个左边按钮
//    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"左边" style:UIBarButtonItemStylePlain target:self action:@selector(clickLeftButton)];
//    //创建一个右边按钮
//    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"右边" style:UIBarButtonItemStyleDone target:self action:@selector(clickRightButton)];
//    
//    self.navigationController.navigationBar.translucent = NO;
//    
//    //设置导航栏的内容
//    [navItem setTitle:@"凌凌漆"];
//    
//    //把导航栏集合添加到导航栏中，设置动画关闭
//    [navBar pushNavigationItem:navItem animated:NO];
//    //navBar.backgroundColor = HH;
//        //把左右两个按钮添加到导航栏集合中去
//    [navItem setLeftBarButtonItem:leftButton];
//    [navItem setRightBarButtonItem:rightButton];
//        //将标题栏中的内容全部添加到主视图当中
//    [self.view addSubview:navBar];
//    

    
}
-(void) clickLeftButton
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void) clickRightButton
{
    
    
    self.fenVIE = [[UIView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 163.00*HEIGHT)];
    
    self.fenVIE.alpha = 0.9;
    self.fenVIE.backgroundColor =[UIColor colorWithWhite:0.500 alpha:1.000];
    _fenVIE.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_fenVIE];
    
//    self.BaiView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height- 163.00*HEIGHT/2, self.view.frame.size.width, 163.00*HEIGHT)];
//    self.BaiView.alpha = 0.0;
//    self.BaiView.backgroundColor = [UIColor whiteColor];
    NSLog(@"aaaaaa分享");
    if (self.isSelrct) {
        NSLog(@"点击了分享");
        
        [UIView animateWithDuration:0.004 animations:^{
            
            
        } completion:^(BOOL finished) {
            
            
        }];
    }
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



//弹出列表方法presentSnsIconSheetView需要设置delegate为self
-(BOOL)isDirectShareInIconActionSheet
{
    return YES;
}


-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的微博平台名
        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
